﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using ZMHModels;

namespace ZMHWcfServiceLibrary
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码和配置文件中的类名“WCFWithDataContractSVC”。
    public class WCFWithDataContractSVC : IWCFWithDataContractSVC
    {
        public void DoWork()
        {
        }

        public List<Car> GetCarInfo()
        {
            return new List<Car>
            {
                new Car{Name="BMW 5" ,Price=623243},
                new Car{Name="Benz e300",Price=423434},
                new Car{Name="BMW 3" ,Price=323243},
                new Car{Name="Benz e200",Price=293434},
            };
        }

        public Dictionary<int, Stu> GetDicInfo()
        {
            Dictionary<int, Stu> dicStInfo = new Dictionary<int, Stu>();
            dicStInfo.Add(10001, new Stu { Name = "xx", Age = 12, DicScore = GetScoreInfo(81.2, 65.2, 73.2, 99, 93.2) });
            dicStInfo.Add(10002, new Stu { Name = "yy", Age = 13, DicScore = GetScoreInfo(63.2, 73.2, 69, 64.2) });
            dicStInfo.Add(10003, new Stu { Name = "zz", Age = 13, DicScore = GetScoreInfo(65.2, 77.2, 61) });
            return dicStInfo;
        }

        private Dictionary<string, double> GetScoreInfo(params double[] sList)
        {
            Dictionary<string, double> dicx = new Dictionary<string, double>();
            int i = 1;
            foreach (var item in sList)
                dicx.Add($"Math{i++}", item);
            return dicx;
        }

        public List<Stu> GetStuList()
        {
            return new List<Stu>
            {
                new Stu{Name="zzz0",Age=23},
                new Stu{Name="zzz1",Age=24},
                new Stu{Name="zzz2",Age=25},
                new Stu{Name="zzz3",Age=26},
                new Stu{Name="zzz4",Age=27},
            };
        }

        public void InsertStu(List<Stu> stuList)
        {
        }
    }
}
